home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo9.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  6.4 KB  |  172 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9.  
  10. /***********************************************************************/
  11.  
  12. long __stack = 8192;
  13. struct Library *MUIMasterBase;
  14.  
  15. /***********************************************************************/
  16.  
  17. #ifndef MAKE_ID
  18. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  19. #endif
  20.  
  21. /***********************************************************************/
  22.  
  23. #define ROWS     10
  24. #define COLS      7
  25. #define HSPACE    1
  26. #define VSPACE    1
  27. #define PIC(x,y) (x+y*COLS)
  28.  
  29. struct MUIS_TheBar_Button buttons[] =
  30. {
  31.     {PIC(2,2),  0, "Rea_d"},
  32.     {PIC(1,7),  1, "_Edit"},
  33.     {PIC(0,6),  2, "De_lete"},
  34.     {PIC(1,6),  3, "Ge_TAdd"},
  35.     {PIC(1,9),  4, "_New"},
  36.     {PIC(1,5),  5, "_Reply"},
  37.     {PIC(2,3),  6, "For_ward"},
  38.     {PIC(2,5),  7, "Fetc_h"},
  39.     {PIC(2,7),  8, "_Send"},
  40.     {PIC(3,5),  9, "S_earch"},
  41.     {PIC(0,9), 10, "F_ilter"},
  42.     {PIC(1,0), 11, "_Filters"},
  43.     {PIC(0,1), 12, "_Abook"},
  44.     {PIC(0,3), 13, "_Config"},
  45.     {MUIV_TheBar_End},
  46. };
  47.  
  48. /***********************************************************************/
  49.  
  50. char *appareances[] = {"Images and text","Images","Text",NULL};
  51. char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
  52.  
  53. int
  54. main(int argc,char **argv)
  55. {
  56.     int res;
  57.  
  58.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  59.     {
  60.         Object *app, *win, *sb, *appareance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
  61.  
  62.         if (app = ApplicationObject,
  63.                 MUIA_Application_Title,         "TheBar Demo9",
  64.                 MUIA_Application_Version,       "$VER: TheBarDemo9 1.0 (2.7.2003)",
  65.                 MUIA_Application_Copyright,     "Copyright 2003 by Alfonso Ranieri",
  66.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  67.                 MUIA_Application_Description,  "TheBar example",
  68.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  69.  
  70.                 SubWindow, win = WindowObject,
  71.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  72.                     MUIA_Window_Title,          "TheBar Demo9",
  73.                     WindowContents, VGroup,
  74.                         Child, sb = TheBarVirtObject,
  75.                             GroupFrame,
  76.                             MUIA_Group_Horiz,            TRUE,
  77.                             MUIA_TheBar_EnableKeys,      TRUE,
  78.                             MUIA_TheBar_Buttons,         buttons,
  79.                             MUIA_TheBar_Strip,           "PROGDIR:Pics/SimpleMail",
  80.                             MUIA_TheBar_StripRows,       ROWS,
  81.                             MUIA_TheBar_StripCols,       COLS,
  82.                             MUIA_TheBar_StripHorizSpace, HSPACE,
  83.                             MUIA_TheBar_StripVertSpace,  VSPACE,
  84.                         End,
  85.                         Child, VGroup,
  86.                             GroupFrameT("Settings"),
  87.                             Child, HGroup,
  88.                                 Child, Label2("Appareance"),
  89.                                 Child, appareance = MUI_MakeObject(MUIO_Cycle,NULL,appareances),
  90.                                 Child, Label2("Label pos"),
  91.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  92.                             End,
  93.                             Child, HGroup,
  94.                                 Child, HSpace(0),
  95.                                 Child, Label1("Borderless"),
  96.                                 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  97.                                 Child, HSpace(0),
  98.                                 Child, Label1("Sunny"),
  99.                                 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  100.                                 Child, HSpace(0),
  101.                                 Child, Label1("Raised"),
  102.                                 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  103.                                 Child, HSpace(0),
  104.                                 Child, Label1("Scaled"),
  105.                                 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  106.                                 Child, HSpace(0),
  107.                             End,
  108.                         End,
  109.                         Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  110.                     End,
  111.                 End,
  112.             End)
  113.         {
  114.             ULONG sigs = 0, id;
  115.  
  116.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  117.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  118.  
  119.             set(win,MUIA_Window_Open,TRUE);
  120.  
  121.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  122.             {
  123.                 if (id==TAG_USER)
  124.                 {
  125.                     ULONG appareanceV, labelPosV, borderlessV, sunnyV, raisedV, scaledV;
  126.  
  127.                     get(appareance,MUIA_Cycle_Active,&appareanceV);
  128.                     get(labelPos,MUIA_Cycle_Active,&labelPosV);
  129.                     get(borderless,MUIA_Selected,&borderlessV);
  130.                     get(sunny,MUIA_Selected,&sunnyV);
  131.                     get(raised,MUIA_Selected,&raisedV);
  132.                     get(scaled,MUIA_Selected,&scaledV);
  133.  
  134.                     SetAttrs(sb,MUIA_TheBar_ViewMode,   appareanceV,
  135.                                 MUIA_TheBar_LabelPos,   labelPosV,
  136.                                 MUIA_TheBar_Borderless, borderlessV,
  137.                                 MUIA_TheBar_Sunny,      sunnyV,
  138.                                 MUIA_TheBar_Raised,     raisedV,
  139.                                 MUIA_TheBar_Scaled,     scaledV,
  140.                                 TAG_DONE);
  141.                 }
  142.  
  143.                 if (sigs)
  144.                 {
  145.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  146.                     if (sigs & SIGBREAKF_CTRL_C) break;
  147.                 }
  148.             }
  149.  
  150.             MUI_DisposeObject(app);
  151.  
  152.             res = RETURN_OK;
  153.         }
  154.         else
  155.         {
  156.             printf("%s: can't create application\n",argv[0]);
  157.             res = RETURN_FAIL;
  158.         }
  159.  
  160.         CloseLibrary(MUIMasterBase);
  161.     }
  162.     else
  163.     {
  164.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  165.         res = RETURN_ERROR;
  166.     }
  167.  
  168.     return res;
  169. }
  170.  
  171. /***********************************************************************/
  172.